% align the total allocations to the total emissions by creating one artifitial firm taking the remaining
% allocation 
function[datafac_norm,norm1_average]=data_norm1(datafac,supply_yearly) 
    l=size(datafac,1);
    denom=zeros(l,1);
    for i=1:l
        t=datafac.period(i);
        denom(i)=supply_yearly.supply(supply_yearly.period==t);
    end

    q=datafac.emi./denom; %normalized empirical ex post efficient
    q=table(q);
    datafac_norm=[datafac q];

    r=datafac.alloc./denom; %normalized empirical allocation by designer
    r=table(r);
    datafac_norm=[datafac_norm r];

    fac=unique(datafac.fac);
    nfac=length(fac);
    
    norm1_average=zeros(l,1);
    fac_ea=zeros(nfac,1);
    for j=1:nfac
        facid=fac(j);
        facave=mean(datafac_norm.q(datafac_norm.fac==facid));
        norm1_average(datafac_norm.fac==facid)=facave;
        fac_ea(j)=facave;
    end
    datafac_norm.norm1_average=norm1_average;
end


